﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.Security;
using System.Collections;
using Webchatting.Common;
using Webchatting.Dal;


public partial class server_DeleteGroupMem : System.Web.UI.Page
{
    public static ArrayList arrGroupIds = new ArrayList();
    public static ArrayList arrGroupNames = new ArrayList();
    public static ArrayList arrGroupDess = new ArrayList();
    public static ArrayList arrFRUIds = new ArrayList();
    // public static ArrayList arrFRURemarkNames = new ArrayList();
    public static ArrayList arrFRUNickNames = new ArrayList();
    public static ArrayList arrGroupMemIds = new ArrayList();
    public static ArrayList arrGroupMemRemarkNames = new ArrayList();
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void btnListMyCreatedGroup_Click(object sender, EventArgs e)
    {
        FormsIdentity id = (FormsIdentity)User.Identity;
        OperationGroup Ogroup = new OperationGroup();
        string mygroup = Ogroup.LoadMyGroupDetails(id.Ticket.UserData.Split('@')[0], arrGroupIds, arrGroupNames, arrGroupDess);
        ltlResult.Visible = true;
        ltlText.Visible = true;

        ltlResult.Text = "<b>我创建的群：</b><br/>" + mygroup;
        ltlText.Text = "<b>请选择要操作的群ID：</b>";
        ddlSelectGroup.Visible = true;
        btnDeletegroupMum.Visible = true;
        while (ddlSelectGroup.Items.Count > 0)
        {
            ddlSelectGroup.Items.RemoveAt(0);
        }

        for (int i = 0; i < arrGroupIds.Count; i++)
        {
            ddlSelectGroup.Items.Add(new ListItem((string)arrGroupIds[i], (string)arrGroupIds[i]));
        }

    }
    protected void btnDeletegroupMum_Click(object sender, EventArgs e)
    {
         OperationGroup Ogroup = new OperationGroup();
        int selected = ddlSelectGroup.SelectedIndex;
        string mygroupMem = Ogroup.LoadGroupMum(arrGroupIds[selected].ToString(), arrGroupMemIds, arrGroupMemRemarkNames);
        ltlResult0.Visible = true;
        ltlText0.Visible = true;
        ltlResult0.Text = "<b>我的群成员：</b><br/>" + mygroupMem;
        ltlText.Text = "<b>请选择要踢出的群成员ID：</b>";
        ddlSelectGroupMem.Visible = true;
        btnDeletegroupMumOne.Visible = true;
        while (ddlSelectGroupMem.Items.Count > 0)
        {
            ddlSelectGroupMem.Items.RemoveAt(0);
        }

        for (int i = 0; i < arrGroupMemIds.Count; i++)
        {
            ddlSelectGroupMem.Items.Add(new ListItem((string)arrGroupMemIds[i], (string)arrGroupMemIds[i]));
        }
    }
    protected void btnDeletegroupMumOne_Click(object sender, EventArgs e)
    {
         OperationGroup Ogroup = new OperationGroup();
         int selected0 = ddlSelectGroup.SelectedIndex;
         int selected = ddlSelectGroupMem.SelectedIndex;
         FormsIdentity id = (FormsIdentity)User.Identity;
         try
         {


             Ogroup.DeleteGroupMum(arrGroupIds[selected0].ToString(), arrGroupMemIds[selected].ToString());
             Response.Write("<script>alert('删除群成员成功!');window.parent.location.href='DeleteGroupMem.aspx';</script>");
         }
         catch
         {
             Javascript.GoHistory(-1, "删除失败", Page);
         }


    }
}
